<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
  <title>我的桌面</title>
    <meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" href="css/jiangyi/desktop.css" type="text/css"></link>
<!-- JQuery UI样式 -->	
<link rel="stylesheet" href="easyui/themes/default/easyui.css" type="text/css"></link>
<!-- JQuery基础脚本库 -->
<script type="text/javascript" src="easyui/jquery-1.8.3.js"></script>
<!-- JQuery　 UI所有的插件脚本库-->
<script type="text/javascript" src="easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
/*
	//3.在datetimebox控件中回填显示日期
	var mytime;  
	$("#updatecreatedate").datetimebox({
		  formatter:formattime
	});
*/
	$("#adddlg").dialog({closed:true});
	$("#updatedlg").dialog({closed:true});	
	$("#showInfoNotes").window({closed:true});
	$("#showInfoNotice").window({closed:true});
	
	$("#dg").datagrid({	  		
		url:"memo/findAll.do?id="+$("#aa").val(),
		striped:true,	  			
		rownumbers:true,
		pagination:true,
		pageList:[5],
		/*frozenColumns : [ [ {  
                field : "ck",  
                checkbox : true  
         } ] ], */  
		columns:[[{
			title:"便签标题",
			field:"title",
			width:100,
			align:"center",
			formatter:function(value,row,index){
			//alert(value);
				return "<a onclick='findByTitle1("+row.id+")' href='javascript:void(0)'>"+value+"</a>";
	  		}
		},{
			title:"便签编号",
			field:"id",
			width:60,
			align:"center"
		},{
			title:"创建时间",
			field:"createdate",
			width:100,
			align:"center",
			formatter:formattime
		},{
			title:"操作",
			field:"userid",
			width:100,
			align:"center",
			formatter:function (value,row,index){
			//alert(value);
				return "<a onclick='update("+row.id+")' href='javascript:void(0)'>修改</a>&nbsp;&nbsp;<a onclick='del("+row.id+")' href='javascript:void(0)'>删除</a>";
			}
		}]]	
	});
//通告列表显示
	$("#dgnotice").datagrid({	  		
		url:"announce/findAll.do",
		striped:true,	  			
		rownumbers:true,
		pagination:true,
		pageList:[5],
		/*frozenColumns : [ [ {  
                field : "ck",  
                checkbox : true  
         } ] ], */  
		columns:[[{
			title:"通告标题",
			field:"title",
			width:269,
			align:"center",
			formatter:function(value,row,index){
				return "<a href='announce/findById.do?id="+row.id+"'>"+value+"</a>";
	  		}
		},{
			title:"创建时间",
			field:"createdate",
			width:100,
			align:"center",
			formatter:formattime
		}]]	
	});

//待办事项申请
	$("#dgwatting").datagrid({	  		
		url:"verify/findAll.do",
		striped:true,	  			
		rownumbers:true,
		pagination:true,
		pageList:[5],
		/*frozenColumns : [ [ {  
                field : "ck",  
                checkbox : true  
         } ] ], */  
		columns:[[{
			title:"申请单标题",
			field:"applyid",
			width:269,
			align:"center",
			formatter:function(value,row,index){
			alert(value);
				return "<a href='seal/findByCreateid.do?applyid="+row.id+"'>"+value+"</a>";
	  		}
		},{
			title:"审核状态",
			field:"result",
			width:100,
			align:"center",
			formatter:function (value){
 					if(value==0){
 						return "保存";
 					}else if(value==1){
 						return "提交";
 					}else if(value==2){
 						return "审核中";
 					}else if(value==3){
 						return "审核通过";
 					}else if(value==4){
 						return "已拒绝";
 					}else if(value==5){
 						return "已打回";
 					}
      		}
		},{
			title:"操作",
			field:"userid",
			width:100,
			align:"center",
			formatter:function (value,row,index){
			//alert(value);
				return "<a onclick='update("+row.id+")' href='javascript:void(0)'>修改</a>&nbsp;&nbsp;<a onclick='del("+row.id+")' href='javascript:void(0)'>删除</a>";
			}
		}]]	
	});


//点击添加文字 --添加便签
$("#adds").click(function(){
  	$("#adddlg").dialog("open");
});
$("#adddlg").dialog({
    title: "<img src='images/jiangyi/tDesktop/u114.png'/> 添加便签",
    width: 400,
    height: 350,
    closed: true,
    buttons:[{
		text:"添加",
		handler:function(){
			var data ="title="+$("#addtitle").val()+
 				"&remark="+$("#addremark").val()+
 				"&createdate="+$("#addcreatedate").val()+
 				"&userid="+$("#adduserid").val();
			$.get("memo/add.do",data,function(data){
						alert(data);
						$("#adddlg").dialog("close");
						$("#dg").datagrid("reload");
					},"text");  	
		}
	},{
		text:"取消",
		handler:function(){
			$("#adddlg").dialog("close");
		}
	}]
});			
//修改便签
$("#updatedlg").dialog({
	    title: "修改便签",
	    width: 400,
	    height: 350,
	    closed: true,
	    buttons:[{
			text:"修改",
			handler:function(){
				var data ="id="+$("#updateid").val()+
				"&title="+$("#updatetitle").val()+
  				"&remark="+$("#updateremark").val()+
  				"&createdate="+$("#updatecreatedate").val()+
  				"&userid="+$("#updateuserid").val();
				$.get("memo/update.do",data,function(data){
						alert(data);
						$("#updatedlg").dialog("close");
						$("#dg").datagrid("reload");
						},"text");  	
			}
		},{
			text:"取消",
			handler:function(){
				$("#updatedlg").dialog("close");
			}
		}]
	});	
		
});

//修改便签
function update(value){
		$("#updatedlg").dialog("open");	
		$.post("memo/findById.do","id="+value,function(data){
			$("#updateid").val(value);
			$("#updatetitle").val(data.title);
			$("#updateremark").val(data.remark);
			var cr =formattime(data.createdate);
			$("#updatecreatedate").val(cr);
			$("#updateuserid").val(data.userid);
		},"json");
	};
//删除便签
function del(value){
	$.messager.confirm("提示框", "你确定要删除吗?",function(r){
		if(r){
			var data = "id="+value;
				$.post(
	  				"memo/delete.do",
	  				data,
	  				function(data){
	  				alert(data);
	  				$("#dg").datagrid("reload");
	  				},
	  				"text"
	  			);
			}
	});
};
//格式化数据库日期函数
function formattime(val) {
	//1.转化date的JavaScript
	var year=parseInt(val.year)+1900;
	var month=(parseInt(val.month)+1);
	month=month>9?month:('0'+month);
	var date=parseInt(val.date);
	date=date>9?date:('0'+date);
	var time=year+'-'+month+'-'+date;
	    return time;
}
    
//点击便签列表标题超链接打开详细信息
function findByTitle1(value){
	$("#showInfoNotes").window("open");	
	$.post("memo/findById.do","id="+value,function(data){
			$("#siid").val(value);
			$("#sititle").val(data.title);
			$("#siremark").val(data.remark);
			var cr =formattime(data.createdate);
			$("#sicreatedate").val(cr);
			$("#siuserid").val(data.userid);
		},"json");

}
	    
</script>  
</head>

<body>

<div id="mycontent">
	<!--待处理任务-->
	<div id="mytask">
		<div class="title">&nbsp;&nbsp;
				<img src="images/jiangyi/tDesktop/inbox.png"/>&nbsp;&nbsp;待处理任务
				<a class="more" href="#">更多&gt;&gt;</a>
		</div>
		
		<table id="dgwatting"></table>
		<div class="table">
			<table class="easyui-datagrid"
			    data-options="url:'datagrid_data.json',fitColumns:true,singleSelect:true">
			    <thead>
					<tr>
						<th data-options="field:'taskname',align:'center'">任务名称</th>
						<th data-options="field:'taskstatus',align:'center'">状态</th>
						<th data-options="field:'taskhandle',align:'center'">操作</th>
					</tr>
			    </thead>
			    <tbody>
					<tr>
						<td>张三请假申请</td>
						<td>待审核</td>
						<td><a href="#">审核</a>&nbsp;&nbsp;<a href="#">查看</a></td>
					</tr>
					<tr>
						<td>李四请假申请</td>
						<td>审核中</td>
						<td><a href="#">审核</a>&nbsp;&nbsp;<a href="#">查看</a></td>
					</tr>
				</tbody>
			</table>
		</div>	
	</div>
	<!--通知公告-->
	<div id="mynotice">
		<div class="title">&nbsp;&nbsp;
			<img src="images/jiangyi/tDesktop/pdf.png"/>&nbsp;&nbsp;通知公告
			<a class="more" href="javascript:window.location.href='jsp/noticeList.jsp'">更多&gt;&gt;</a>
		</div>
		<table id="dgnotice"></table>
	</div>
	<!--我的便签-->
	<div id="mymemo">
		<div class="title">
			<ul>
				<li>&nbsp;&nbsp;<img src="images/jiangyi/tDesktop/pen.png"/>&nbsp;&nbsp;我的便签</li>
				<li id="adds">
					<img id="" src="images/jiangyi/tDesktop/u130.png"/>
					<a id="add" href="javascript:;">添加</a>
				</li>
			</ul>
		</div>
		<input type="hidden" id="aa" value="${user.id }"/>
		<table id="dg"></table>
		<table id="adddlg">
      		<tr>
      			<td>标题</td>
      			<td><input type="text" name="addtitle" id="addtitle"></td>
      		</tr>
      		<tr>
      			<td>时间</td>
      			<td><input type="text" name="addcreatedate" id="addcreatedate"><label>日期格式为：xxxx-xx-xx</label></td>
      		</tr>
      		<tr>
      			<td>用户</td>
      			
      			<td>
      			<input type="hidden" value="${user.id}" id="adduserid" />
      			<input value="${user.name}" type="text" name="adduserid" id="adduserid1"></td>
      		</tr>
      		<tr>
      			<td>内容</td>
      			<td>
      				<textarea rows="5" cols="14" name="addremark" id="addremark"></textarea>
      			</td>
      		</tr>
      	</table>
      	<table id="updatedlg">
      		<tr>
      			<td>标题</td>
      			<td><input type="hidden" name="memo.id" id="updateid">
      			<input type="text" name="updatetitle" id="updatetitle"></td>
      		</tr>
      		<tr>
      			<td>时间</td>
      			<td><input type="text" name="updatecreatedate" id="updatecreatedate"></td>
      		</tr>
      		<tr>
      			<td>用户</td>
      			<td>
      			<input type="hidden" value="${user.id}" id="updateuserid" />
      			<input value="${user.name}" type="text" name="updateuserid" id="updateuserid1">
      			</td>
      		</tr>
      		<tr>
      		<tr>
      			<td>内容</td>
      			<td>
      				<textarea rows="5" cols="14" name="updateremark" id="updateremark"></textarea>
      			</td>
      		</tr>
      	</table>
      	
		
	    <div id="showInfoNotes" class="easyui-window" 
		      	title="<input style='width:400px;height:20px;' type='text' name='sititle' 
		      	id='sititle'>" style="width:400px;height:300px"
		    		data-options="iconCls:'icon-save',modal:true">
		    	<div class="easyui-layout" data-options="fit:true">
				内容：
					<div data-options="region:'center'">
						<input type="hidden" name="memo.id" id="siid">
						<input type="hidden" name="siuserid" id="siuserid"><br/>
			      	<textarea style="text-align:center;" rows="10" cols="43" name="siremark" id="siremark"></textarea>
					</div>
		    	</div>
		</div>
 	</div>
	<!--常用工具-->
	<div id="mytool">
		<div class="title">&nbsp;&nbsp;
			<img src="images/jiangyi/tDesktop/map.png"/>&nbsp;&nbsp;常用网址
		</div>
		<div id="icons" style="margin-left:20px 30px">
			<ul>
				<li class="tools">
					<img src="images/jiangyi/tDesktop/111.jpg"/><br/><br/>
					<a href="javascript:window.location.href='jsp/tUrls.jsp'">常用网址</a>
				</li>
				
			</ul>
		</div>
	</div>


</div>

</body>
</html>
